<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript"></script>
<script>
$(document).ready(function(){
		$('#chrcount').keyup(function(){
			var len = $('#chrcount').val();
			var char = len.length;	
			if(254-char == 0){
				}
			$('#chrcountlength').html(255-char);	
		});
	});
	
	$(document).ready(function(){
		$('#chrcount2').keyup(function(){
			var len = $('#chrcount2').val();
			var char = len.length;	
			if(254-char == 0){
				}
			$('#chrcountlength2').html(255-char);	
		});
	});
</script>

<div id="mws-container" class="clearfix">
<div class="container">
  <div class="mws-panel grid_8">
    <div class="mws-panel-header"> <span class="mws-i-24 i-list">Add Brand</span> </div>
    <div class="mws-panel-body">
      <div class="mws-form-inline">
       <?php echo $form->create(array('controller'=>'setups','action'=>'','method'=>'post','enctype'=>'multipart/form-data', 'class' => 'mws-form')); ?>
<?php 
		if(isset($details['Brand']['id'])){$details['Brand']['id']=$details['Brand']['id'];}else{$details['Brand']['id']="";}
		echo $this->Form->input('Brand.id', array('type' => 'hidden','value'=>$details['Brand']['id']));
?>

        <div class="mws-form-row">
          <label>* Title :</label>
          <div class="mws-form-item small"> <?php 
if(isset($details['Brand']['name'])){$details['Brand']['name']=$details['Brand']['name'];}else{$details['Brand']['name']="";}
echo $this->Form->input('Brand.name', array('type' => 'text','value'=>$details['Brand']['name'],'class'=>'mws-textinput','label' =>false));?> 
          </div>
        </div>
        <div class="mws-form-row">
          <label>* Keyword :</label>
          <div class="mws-form-item small"> <?php 
		  if(isset($details['Brand']['keyword'])){$details['Brand']['keyword']=$details['Brand']['keyword'];}else{$details['Brand']['keyword']="";}

		  echo $this->Form->input('Brand.keyword', array('type' => 'teatarea','value'=>$details['Brand']['keyword'], 'rows'=>'5','cols'=>'44', 'class'=>'mws-textinput','label' =>false));?> </div>
        </div>
        <div class="mws-form-row">
          <label>* Suggested Names :</label>
          <div class="mws-form-item small"> <?php 
		  if(isset($details['Brand']['suggested_name']))
		  	{
				$details['Brand']['suggested_name']=$details['Brand']['suggested_name'];
			}
		 else
		 	{
				$details['Brand']['suggested_name']="";
			}
			 
		  //$explode_brands = explode(',', $details['Brand']['suggested_name']);
		  //pr( $explode_brands);
		  
		  
		  
		  echo $this->Form->input('Brand.suggested_name', array('type' => 'teatarea','value'=>$details['Brand']['suggested_name'], 'rows'=>'5','cols'=>'44', 'class'=>'mws-textinput','label' =>false));?> </div>
        </div>
        <div class="mws-form-row">
          <label>Sort Type :</label>
          <div class="mws-form-item 	small">
	<?php
			if(isset($details['Brand']['sort'])){$details['Brand']['sort']=$details['Brand']['sort'];}else{$details['Brand']['sort']="";}
			echo $this->Form->input('Brand.sort', array('type' => 'text','value'=>$details['Brand']['sort'],'class'=>'mws-textinput','label' =>false));
	?>
 </div>
        </div>
        
        
         <div class="mws-form-row">
          <label>Category :</label>
          <div class="mws-form-item 	small">
			 <?php
				 if(isset($details['Brand']['cat_id'])){
					 
					 	$details['Brand']['cat_id']=$details['Brand']['cat_id'];
						$new_cat = explode(', ',$details['Brand']['cat_id']);
						foreach($new_cat as $new_c)
						{
							$cat_ides[$new_c] = $new_c;
						}
						//pr($cat_ides);
						
						
						}
						else{$details['Brand']['cat_id']="";}
						$selected_parent ="";
						$selected_Sub_1_Cat ="";
						$selected_Sub_2_Cat ="";
						
                    if($_list_categories and $_list_categories)
                        {	
               ?>
                           <select id="CategoryPid"  multiple="multiple"  style="height:190px;" class="mws-textinput" name="data[Brand][cat_id][]">
                           <?php
						   $x__2 = 0;
                                foreach($_list_categories as $_Parent_cats)
                                    {	
										if(isset($cat_ides[$_Parent_cats['Category']['id']]) and ($cat_ides[$_Parent_cats['Category']['id']]) and ($cat_ides[$_Parent_cats['Category']['id']] == $_Parent_cats['Category']['id'])) 
											{
												$selected_parent = "selected='selected'"; 
											}
											else
											{
												$selected_parent ="";
											}
                           ?>			
                                        <option <?php echo $selected_parent; ?> value="<?php echo $_Parent_cats['Category']['id']; ?>" 
                                        class="cat_grp_1"><?php echo $_Parent_cats['Category']['name']; ?></option>
                                       <?php
                                       $ko = 0;
                                            foreach($_Parent_cats['Category']['Sub_1_Cat'] as $Sub_1_Cat)
                                                {
													if(isset($cat_ides[$Sub_1_Cat['Category']['id']]) and ($cat_ides[$Sub_1_Cat['Category']['id']]) and ($cat_ides[$Sub_1_Cat['Category']['id']] == $Sub_1_Cat['Category']['id']))
														{
															$selected_Sub_1_Cat = "selected='selected'"; 
														}
														else
														{
															$selected_Sub_1_Cat ="";
														}
                                                    echo "<option ".$selected_Sub_1_Cat." value=".$Sub_1_Cat['Category']['id']." class='cat_grp_2'>
                                                   &bull;&nbsp;&nbsp;".$Sub_1_Cat['Category']['name']."
                                                    </option>";
                                                    if(isset($Sub_1_Cat['Category']['Sub_2_cat']) and ($Sub_1_Cat['Category']['Sub_2_cat']))
                                                        {
                                                            $bn=0;
                                                            $Sub_2_cats = $Sub_1_Cat['Category']['Sub_2_cat'][$ko];
                                                             foreach($Sub_2_cats as $Sub_2_cat)
                                                                {
																	if(isset($cat_ides[$Sub_2_cat['Category']['id']]) and ($cat_ides[$Sub_2_cat['Category']['id']]) and ($cat_ides[$Sub_2_cat['Category']['id']] == $Sub_2_cat['Category']['id']))
																		{
																			$selected_Sub_2_Cat = "selected='selected'"; 
																		}
																		else
																		{
																			$selected_Sub_2_Cat ="";
																		}
							echo "<option  ".$selected_Sub_2_Cat." value=".$Sub_2_cat['Category']['id']." class='cat_grp_3 '>
                                                                       &loz;&nbsp;&nbsp;".$Sub_2_cat['Category']['name']."</option>";
                                                                    $bn++;
                                                                }
                                                        }
                                               $ko++; }
                           ?>
                           <?php
                                    $x__2++;}
                           ?>            
                            </select> 
               <?php
                        }
               ?> 
 </div>
        </div>
        
        
	             

        
        
        
        
        
        <div class="mws-form-row">
        <label>Browse Image:</label>
        <div class="mws-form-item 	small"> 
		<?php echo $this->Form->input('Brand.imgImage', array('type' => 'file','value'=>'','class'=>'','label' =>false));?> </div>
        </div>
        <div class="mws-form-row">
          <label>Status Type :</label>
          <div class="mws-form-item 	small">
		<?php 
		if(isset($details['Brand']['status'])){$details['Brand']['status']=$details['Brand']['status'];}else{$details['Brand']['status']="";}
			$options = array('1'=>'Active', '0'=>'Deactive'); 
			echo $this->Form->input('Brand.status', 
			array('type' => 'select','options'=>$options,
			'default'=>$details['Brand']['status'],'class'=>'mws-textinput','empty'=>false,'label' =>false)
			);
        ?>
          </div>
        </div>
        <div class="mws-button-row">
          <input type="submit" class="mws-button black" value="Submit">
        </div>
        </form>
      </div>
    </div>
  </div>
</div>
